#!/usr/bin/ksh

cp /etc/hosts /tmp/hosts2
grep -v '^#' /tmp/hosts2 > /tmp/hosts3 # Strip out comment lines

exec 3< /tmp/hosts3	# fd 3 is an input file /tmp/hosts3
exec 4> /tmp/hostsfinal	# fd 4 is output file /tmp/hostsfinal

read -u3 addr1 name1 alias	# read from fd 3 --> NOTE -u option is Korn shell specific
read -u3 addr2 name2 alias	# read from fd 3

exec 3<&-			# close fd 3

print -u4 $name1 $addr1		# write to fd 4 (do not write aliases)
print -u4 $name2 $addr2		# write to fd 4 (do not write aliases) NOTE the -u option to print is Korn shell

exec 4<&- # close fd 4
